package Game.Online.Messages 
{
	import Box2D.Common.Math.b2Vec2;
	import flash.utils.ByteArray;
	import Game.Online.OnlineManager;
	/**
	 * ...
	 * @author Yevgeniy Logachev
	 */
	public class MessageCorrectPosition extends Message
	{
		public function MessageCorrectPosition(id:String = null)
		{
			if (id == null)
			{
				id = OnlineManager.instance.connection.id;
			}
			super(MessagesDefs.k_MESSAGE_CORRECT_POSITION, id);
			
			setData(0, 0, 0);
		}
		
		public function setData(posx:Number, posy:Number, rotation:int):void
		{
			m_data.position = MSG_OFFSET_ID;
			m_data.readUTF();
			
			m_data.writeDouble(posx);
			m_data.writeDouble(posy);
			m_data.writeInt(rotation);
		}
		
		public function get position():b2Vec2
		{
			m_data.position = MSG_OFFSET_ID;
			m_data.readUTF();
			
			var x:Number = m_data.readDouble();
			var y:Number = m_data.readDouble();
			
			return new b2Vec2(x, y);
		}
		
		public function get rotation():int
		{
			m_data.position = MSG_OFFSET_ID;
			m_data.readUTF();
			
			m_data.readDouble();
			m_data.readDouble();
			
			return m_data.readInt();
		}
	}
}